//
//  UIImageView+JTExtension.m
//  百思不得姐
//
//  Created by Robin Zhang on 2017/1/18.
//  Copyright © 2017年 BeiJingWangDianJieTong. All rights reserved.
//

#import "UIImageView+JTExtension.h"
#import <UIImageView+WebCache.h>

@implementation UIImageView (JTExtension)

/** 设置头像 */
- (void)setHeader:(NSString *)url {
    
    [self setCircleHeader:url];
}

/** 设置圆形头像 */
- (void)setCircleHeader:(NSString *)url {
    
    // 头像
    [self sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage jt_circleImageNamed:@"defaultUserIcon"]/** 圆形的占位图片 */ completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        
        if (!image) return; // 请求失败，那就继续显示占位图片
        
        [self setImage:[image jt_circleImage]];
    }];
}

/** 设置方形头像 */
- (void)setRectHeader:(NSString *)url {
    
    [self sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"defaultUserIcon"]];
}

@end
